using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CodeWork.Library.Web;
using System.Collections;

/// <summary>
/// Summary description for BaseMaster
/// </summary>

namespace CodeWork.Library.Web
{
    public class BaseMaster : System.Web.UI.MasterPage
    {
        public BaseMaster() { }

        public string ResponseMessage
        {
            set
            {
                Label lblMessage = (Label)FindControl("lblMessage");
                if (lblMessage != null)
                    lblMessage.Text = value;
            }
        }

        protected void SetStyleSheetLinksLocation()
        {
            // Changing the stylesheet url that was generated by asp.net automatically to fit
            // the url rewriter
            ArrayList links = new ArrayList();
            HtmlHead head = (HtmlHead)Page.Header;
            IEnumerator myEnumerator = head.Controls.GetEnumerator();
            while (myEnumerator.MoveNext())
            {
                if (myEnumerator.Current is HtmlLink)
                {
                    string oldHref = ((HtmlLink)myEnumerator.Current).Href;
                    if (oldHref.IndexOf("App_Themes") != -1)
                    {
                        links.Add(oldHref);
                        string basePath = Server.MapPath("~");
                        basePath = basePath.Substring(basePath.LastIndexOf("\\") + 1);
                        string newHref = oldHref.Replace("~/App_Themes", "/" + basePath + "/App_Themes");
                        ((HtmlLink)myEnumerator.Current).Href = newHref;
                    }
                }
            }
        }
    }
}
